/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */

package com.pig4cloud.pigx.user.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.user.dto.AppUserApiKeyAddDTO;
import com.pig4cloud.pigx.user.dto.AppUserApiKeyEditDTO;
import com.pig4cloud.pigx.user.dto.UserApiKeyLockDTO;
import com.pig4cloud.pigx.user.entity.UserApiKey;
import com.pig4cloud.pigx.user.vo.AppUserApiKeyAddResVO;
import com.pig4cloud.pigx.user.vo.AppUserApiKeyDetailVO;
import com.pig4cloud.pigx.user.vo.AppUserApiKeyPageVO;
import com.pig4cloud.pigx.user.vo.UserApiKeyCacheVO;
import com.pig4cloud.pigx.user.vo.UserApiKeyInfoVO;
import com.pig4cloud.pigx.user.vo.UserApiKeyVO;

import javax.servlet.http.HttpServletRequest;

/**
 * 用户apiKey
 *
 * @since 2022-10-28 15:47:24
 */
public interface UserApiKeyService extends IService<UserApiKey> {

	/**
	 * 分页查询
	 *
	 * @param page      分页条件
	 * @param condition 查询条件
	 * @return {@link Page< UserApiKeyVO>}
	 * @since 2022/10/28 16:52
	 */
	Page<UserApiKeyVO> page(Page<UserApiKey> page, UserApiKey condition);

	/**
	 * 人工封禁
	 *
	 * @param dto dto
	 * @since 2022/10/31 14:34
	 */
	void lockManual(UserApiKeyLockDTO dto);

	/**
	 * 人工解封
	 *
	 * @param dto dto
	 * @since 2022/10/31 14:34
	 */
	void unlockManual(UserApiKeyLockDTO dto);

	/**
	 * Dapp-分页查询
	 *
	 * @param page      分页数据
	 * @param condition 查询条件
	 * @return {@link Page< AppUserApiKeyPageVO>}
	 * @since 2022/11/1 17:10
	 */
	Page<AppUserApiKeyPageVO> pageApp(Page<UserApiKey> page, UserApiKey condition);

	/**
	 * Dapp-删除全部
	 *
	 * @since 2022/11/1 18:18
	 */
	void removeAll();

	/**
	 * Dapp-删除单挑
	 *
	 * @param id id
	 * @since 2022/11/7 11:13
	 */
	void remove(Long id);

	/**
	 * Dapp-根据id查询详情
	 *
	 * @param id id
	 * @return {@link AppUserApiKeyDetailVO}
	 * @since 2022/11/2 10:42
	 */
	AppUserApiKeyDetailVO appDetail(Long id);

	/**
	 * Dapp-新增
	 *
	 * @param dto dto
	 * @return {@link AppUserApiKeyAddResVO}
	 * @since 2022/11/2 11:42
	 */
	AppUserApiKeyAddResVO add(AppUserApiKeyAddDTO dto);

	/**
	 * 创建ApiKey时获取邮箱验证码
	 *
	 * @param time 客户端当前时间字符串
	 * @param name 标签
	 * @since 2022/11/1 19:52
	 */
	void verifyCodeWhenCreate(HttpServletRequest request, String time, String name);

	/**
	 * Dapp-修改
	 *
	 * @param dto dto
	 * @since 2022/11/3 11:18
	 */
	void edit(AppUserApiKeyEditDTO dto);

	/**
	 * ApiKey提现权限修改为允许时获取邮箱验证码
	 *
	 * @param time 客户端当前时间字符串
	 * @param name 标签
	 * @since 2022/11/1 20:04
	 */
	void verifyCodeWhenModify(String time, String name);

	/**
	 * 根据AccessKey查询ApiKey所有相关信息
	 *
	 * @param accessKey 访问密钥
	 * @return {@link UserApiKeyInfoVO}
	 * @since 2022/11/9 14:35
	 */
	UserApiKeyInfoVO getInfo(String accessKey);

	/**
	 * 根据AccessKey查询信息
	 *
	 * @param accessKey 访问密钥
	 * @return {@link UserApiKeyCacheVO}
	 * @since 2022/11/9 11:08
	 */
	UserApiKeyCacheVO getCache(String accessKey);

	/**
	 * 根据 accessKey 查询 secretKey
	 * @param accessKey 访问密钥
	 * @param verifyCode 验证码
	 * @return r
	 */
	R<String> getSecretKey(String accessKey,String verifyCode);

	/**
	 * 用户查询 secretKey 时发送邮件
	 *
	 * @param time 客户端当前时间字符串
	 * @param name 标签
	 * @return r
	 */
	R verifyCodeWhenGetSecretKey(String time, String name);
}
